import { createAPI } from '@/api/http';
import { Opts } from '@/api/opts';

/**
 *  @description 添加角色权限
 *  @name addCasbin
 *  @param  roleId 角色ID {string} 必传参数
 *  @param  apisId 接口ID {array} 必传参数

 *  @example 示例1
 *   onMounted(async () => {
 *     const { data } = await createUser({ data: { id: '1' } });
 *   });
 *  @example 示例2
 *  createUser({ data: { id: '1' } }).then(res => {});
 *  @example 示例3
 *  const { data } = await deleteUser({ params: { id: '1' } })
 */
export const addCasbin = (opts: Opts) =>
  createAPI({
    method: 'post',
    url: '/wit/casbin/addCasbin',
    opts,
  });

/**
 *  @description 添加用户角色
 *  @name addRolesForUser
 *  @param  userId 用户ID {string} 必传参数
 *  @param  roleId 角色ID {array} 必传参数

 *  @example 示例1
 *   onMounted(async () => {
 *     const { data } = await createUser({ data: { id: '1' } });
 *   });
 *  @example 示例2
 *  createUser({ data: { id: '1' } }).then(res => {});
 *  @example 示例3
 *  const { data } = await deleteUser({ params: { id: '1' } })
 */
export const addRolesForUser = (opts: Opts) =>
  createAPI({
    method: 'post',
    url: '/wit/casbin/addRolesForUser',
    opts,
  });

/**
 *  @description 删除角色权限
 *  @name deleteCasbin
 *  @param  roleId 角色ID {string} 必传参数
 *  @param  apisId 接口ID {array} 必传参数

 *  @example 示例1
 *   onMounted(async () => {
 *     const { data } = await createUser({ data: { id: '1' } });
 *   });
 *  @example 示例2
 *  createUser({ data: { id: '1' } }).then(res => {});
 *  @example 示例3
 *  const { data } = await deleteUser({ params: { id: '1' } })
 */
export const deleteCasbin = (opts: Opts) =>
  createAPI({
    method: 'delete',
    url: '/wit/casbin/deleteCasbin',
    opts,
  });

/**
 *  @description 删除用户角色
 *  @name deleteRolesForUser
 *  @param  userId 用户ID {string} 必传参数
 *  @param  roleId 角色ID {string} 必传参数

 *  @example 示例1
 *   onMounted(async () => {
 *     const { data } = await createUser({ data: { id: '1' } });
 *   });
 *  @example 示例2
 *  createUser({ data: { id: '1' } }).then(res => {});
 *  @example 示例3
 *  const { data } = await deleteUser({ params: { id: '1' } })
 */
export const deleteRolesForUser = (opts: Opts) =>
  createAPI({
    method: 'delete',
    url: '/wit/casbin/deleteRolesForUser',
    opts,
  });

/**
 *  @description 获取角色权限
 *  @name getCasbinPolicy
 *  @param  roleId 角色ID {string} 必传参数

 *  @example 示例1
 *   onMounted(async () => {
 *     const { data } = await createUser({ data: { id: '1' } });
 *   });
 *  @example 示例2
 *  createUser({ data: { id: '1' } }).then(res => {});
 *  @example 示例3
 *  const { data } = await deleteUser({ params: { id: '1' } })
 */
export const getCasbinPolicy = (opts: Opts) =>
  createAPI({
    method: 'get',
    url: '/wit/casbin/getCasbinPolicy',
    opts,
  });
